package org.swift.mashup.engine.concurrency.agenda;

public class AgendaConfig {
    public static final int DEFAULT_AGENDA_TIMEOUT = 120000;
    public static final int RATE_LIMIT = 100;

    private int agendaTimeout = DEFAULT_AGENDA_TIMEOUT;
    private int rateLimit = RATE_LIMIT;
    private ThreadMonitor threadMonitor = new ThreadMonitor();

    public int getAgendaTimeout() {
        return agendaTimeout;
    }

    public AgendaConfig setAgendaTimeout(int agendaTimeout) {
        if ( agendaTimeout >= 1000 && agendaTimeout <= 300000 ) {
            this.agendaTimeout = agendaTimeout;
        }
        else {
            this.agendaTimeout = DEFAULT_AGENDA_TIMEOUT;
        }
        return this;
    }

    public int getRateLimit() {
        return rateLimit;
    }

    public AgendaConfig setRateLimit(int rateLimit) {
        if ( rateLimit >= 1 && rateLimit < RATE_LIMIT ) {
            this.rateLimit = rateLimit;
        }
        else {
            this.rateLimit = RATE_LIMIT;
        }
        return this;
    }

    public ThreadMonitor getThreadMonitor() {
        return threadMonitor;
    }

    public AgendaConfig setThreadMonitor(ThreadMonitor threadMonitor) {
        this.threadMonitor = threadMonitor;
        return this;
    }

    @Override
    public String toString() {
        return "AgendaConfig{" +
                "agendaTimeout=" + agendaTimeout +
                ", rateLimit=" + rateLimit +
                ", threadMonitor=" + threadMonitor +
                '}';
    }
}
